﻿using System;
using System.Net;
using System.Net.Sockets;
using FinosLibrary.Client;
using FinosLibrary;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BattleShipOnline {
    [MessageProcess]
    public class Chat:ModelLogic {
        private List<string> someMsg = new List<string>(new StringBuilder().Append(',', 4).ToString().Split(','));
        private string _input;
        public string InputText
        {
            get { return _input; }
            set { _input = value; if (value != null) { SendChat(); } else { this.NotifyPropertyChanged(x => x.InputText); } }
        }
        public string ChatText { get; set; }
        public void SendChat() {
            call("chat", InputText);
            InputText = null;
        }
        [MessageMethod]
        public void chat(string msg) {
            someMsg.Add(msg);
            someMsg.RemoveAt(0);
            ChatText = String.Join("\n", someMsg.ToArray());
            this.NotifyPropertyChanged(x => x.ChatText);
        }
    }
}
